﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TimKen.App;

namespace TimKen.Web.User
{
    public partial class CheckUser : TimKen.App.WebPage
    {
        TimKen.BussLogic.WebUserManager wum = new TimKen.BussLogic.WebUserManager();
        protected void Page_Load(object sender, EventArgs e)
        {
            BindResources();
            string code = Request.QueryString["code"];
            if (!string.IsNullOrEmpty(code))
            {
                AuthenticatedUser(code);
            }
        }

        protected void BindResources()
        {

            btCheckUser.Text = GetLangString("AuthenticationUser");
        }
        protected void btCheckUser_Click(object sender, EventArgs e)
        {
            string code = txtCheckCode.Text;
            AuthenticatedUser(code);
        }
        public void AuthenticatedUser(string code)
        {
            string username = Tools.DecryptUserName(code);
            if (wum.Exists(username))
            {
                wum.AuthenticatedUser(username);
                Alert(GetLangString("AuthenticateSuccessful"), "/Index.aspx");
            }
            else
            {
                Alert(GetLangString("AuthenticateFailer"));
            }
        }


    }
}
